#coding=utf-8

import os
import configparser
import threading


class PathPaeser(object):
    def __init__(self,path_config):
        pass
    def __new__(cls, path_config):
        mutex=threading.Lock()
        mutex.acquire() # 上锁，防止多线程下出问题
        if not hasattr(cls, 'instance'):
            cls.instance = super(PathPaeser, cls).__new__(cls)
            config = configparser.ConfigParser()
            config.read(path_config, encoding='utf-8')
            cls.instance.log_config_path = os.path.abspath(config.get('PATH', 'log_config_path'))
            cls.instance.mockfile_path = os.path.abspath(config.get('PATH', 'mockfile_path'))
        mutex.release()
        return cls.instance
    
config_path=os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir,"config","pathconfig.conf"))
PATH=PathPaeser(config_path)